package com.ndp.fb.rdb.model;


import com.alibaba.fastjson.JSON;
import com.ndp.fb.rdb.annotation.Column;
import com.ndp.fb.rdb.annotation.ColumnType;
import com.ndp.fb.rdb.annotation.NoSave;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by Administrator on 2014/12/24.
 */
@Setter
@Getter
@NoArgsConstructor
public class BaseAdLevel implements Serializable {
    //user_id
    private String userId;                  //发布者    ADD BY Evan 2015-07-27
    @NoSave
    private Long preId;                     //预发布id   ADD BY Evan 2015-07-01
    //publish_batch_id
    private Long publishBatchId;
    //publish_batch_name
    private String publishBatchName;
    //publish_result_id
    private Long publishResultId;
    //access_token
    private String accessToken;
    //fb_account_id
    private Long fbAccountId;
    @NoSave
    private String actAccountId;
    //time_zone
    private String timeZone;
    @Column(value = "product_conf_id", type = ColumnType.Long)
    private Long productConfigurationId;
    @Column("product_conf_name")
    private String configuration;
    //fb_connection_object_id
    private Long fbConnectionObjectId;
    //fb_connection_object_name
    private String fbConnectionObjectName;
    @Column(value = "create_utc_time", type = ColumnType.Long)
    private Long createUTCTime;
    @Column(value = "create_time", type = ColumnType.Time)
    private Date createTime;
    @Column(value = "update_utc_time", type = ColumnType.Time)
    private Long updateUTCTime;
    @Column(value = "update_time", type = ColumnType.Long)
    private Date updateTime;

    /**
     * 0 待发布
     * 1 发布成功
     * 2 发布失败
     */
    @Column("stats")
    private Integer status;

    public void setActAccountId(String actAccountId) {
        if (actAccountId.contains("act_")) {
            actAccountId = actAccountId.substring(4);
        }
        this.actAccountId = actAccountId;  // FIXME: 2016/3/8  混乱的关系！！！！
        this.fbAccountId = Long.valueOf(actAccountId);
    }

    public String getActAccountId() {
        return "act_" + fbAccountId;
    }


    public void setFbAccountId(Long accountId) {
        this.fbAccountId = accountId;
        this.actAccountId = "act_" + accountId;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}
